package com.cl.spark.enums;

public enum SparkNodeEnum {

    HTTP_REQUEST("/other/httpRequest", "请求接口"),
    HTTP_REQUEST_EXECUTE("/other/httpRequestExecute", "调用接口"),
    JOIN("/base/join", "连接"),
    UNION("/base/union", "合并"),
    UNION_TABLE("/base/unionTable", "合并表"),
    CREATE_TABLE("createTable", "输出表"),
    SORT("/base/sort", "排序"),
    DROP_DUPLICATES("/base/dropDuplicates", "去重"),
    MATCH("/statistics/match", "完全匹配"),
    CONTAINS_MATCH("/statistics/containsMatch", "模糊匹配"),
    GROUP("/statistics/group", "分类汇总"),

    RULE_HANDLE("/rule/handle", "规则处理"),

    DATA_SOURCE("dataSource", "数据源"),
    KS_RULE("ksRule", "模型"),


    KS_FLOW_GRAPH_CHILD("ksFlowGraphChild", "子流程"),
    SPARK_NODE("sparkNode", "操作"),
    END("end", "结束");

    private final String code;
    private final String nodeName;

    SparkNodeEnum(String code, String nodeName) {
        this.code = code;
        this.nodeName = nodeName;
    }

    public static SparkNodeEnum getSparkNodeByCode(String code) {
        for (SparkNodeEnum e : SparkNodeEnum.values()) {
            if (e.getCode().equals(code)) {
                return e;
            }
        }
        return null;
    }

    public static SparkNodeEnum getSparkNodeByNodeName(String name) {
        for (SparkNodeEnum e : SparkNodeEnum.values()) {
            if (e.getNodeName().equals(name)) {
                return e;
            }
        }
        return null;
    }

    public String getCode() {
        return code;
    }

    public String getNodeName() {
        return nodeName;
    }
}
